package main

import (
	"fmt"
)

/**
Go语言数组
 */
//声明数组
var arrays1 [5] float32

func main() {
	var arr [5] int

	//var arrays2 = [3]float32{100.0, 2.0, 3.0}
	//
	//var array3 = [1]int{100}
	//
	//var array4 = [...]int{100, 200}

	//for i := 0; i < 5; i++ {
	//	arrays1[i] = float32(i + 100); //
	//	if i == 4 {
	//		arrays1[4] = 20.0
	//	}
	//	fmt.Printf("Arr[%d] = %d \n", i, arrays1[i])
	//}

	/** 输出每个数组元素的值 */
	for j := 0; j < 5; j++ {
		arr[j] = j * 5
		if j > 3 {
			arr[j] = 2 * j
		}
		fmt.Printf("Arr[%d] = %d \n", j, arr[j])
	}
	nums := []int{}

	for i := 0; i < 10; i++ {
		nums = GetYangHuiTriangNextLine(nums)
		fmt.Println(nums)
	}

}

/**
打印杨辉三角
 */
func GetYangHuiTriangNextLine(arr []int) []int {
	var out []int
	var i int
	arrlen := len(arr)
	out = append(out, 1)
	if 0 == arrlen {
		return out
	}
	for i = 0; i < arrlen-1; i++ {
		out = append(out, arr[i]+arr[i+1])
	}

	out = append(out, 1)
	return out
}
